﻿using System;
using System.Linq;
using System.Windows.Data;

namespace ForumsBrowser
{
    public class TopToBottomConverter : IValueConverter
    {

        #region IValueConverter Members

        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            double distanceFromBottom = 0;
            if (parameter != null)
                Double.TryParse(parameter.ToString(), out distanceFromBottom);

            double newHeight = (System.Windows.SystemParameters.PrimaryScreenHeight - (double)value) - distanceFromBottom;

            return newHeight;
        }

        public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            throw new NotImplementedException();
        }

        #endregion
    }
}
